package com.departmentstore.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.math.BigDecimal;

@Data
@Entity
@Table(name = "employee")
public class Employee {
    @Id
    @Column(name = "employee_id", length = 10)
    @NotBlank(message = "员工ID不能为空")
    @Size(min = 1, max = 10, message = "员工ID长度必须在1-10之间")
    private String employeeId;

    @Column(name = "name", length = 50)
    @NotBlank(message = "员工姓名不能为空")
    @Size(min = 1, max = 50, message = "员工姓名长度必须在1-50之间")
    private String name;

    @Column(name = "position", length = 50, nullable = true)
    private String position;

    @Column(name = "address", length = 200, nullable = true)
    private String address;

    @Column(name = "salary", precision = 10, scale = 2, nullable = true)
    private BigDecimal salary;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "department_id", nullable = true)
    @JsonIgnore
    private Department department;
} 